<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-CN" lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name ="keywords" content="字符,统计,计数,纯真网络">
<meta name ="Description" content="字符统计，字符计数器">
<title>字符统计</title>
<style type="text/css">
body{font-family:\5B8B\4F53,Arial Narrow,arial,serif; background:#fff; font-size:14px; line-height:21px; color:#060606;}
body,div,img,cite,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,blockquote{margin:0px auto; padding:0px; border:0px;}
table,td,tr,th{font-size:14px;}
input,select,textarea { margin: 0px; border:1px solid #b0bec7; background-color:#fff; line-height:24px; }
cite{ float:right; width:75px; font-style:normal; color: #999; overflow: hidden; white-space:nowrap; font-size:12px; }
div {word-wrap:break-word; }
 
a{color:#004B98;text-decoration:none;}
a:hover{color:#bd0a01;text-decoration:underline; cursor:pointer;}
input{ height: 22px; cursor:pointer; }
input:hover{ color:#bd0a01; -moz-box-shadow:0 0 1px 1px #b0bec7; }
input:focus{ -moz-box-shadow:0 0 1px 1px #b0bec7; }
.submit{cursor:pointer; height: 24px; width:80px;} 

.clear{clear: both; font-size:1px; width:1px; visibility: hidden;}
.hidden{display: none;}

.divbox { height:310px;}
.divbox #top{ color:#fff; font-size:16px; font-weight:bold; height:26px; line-height:26px; background-image:url(images/top.gif); }
.divbox #top a{color:#fff;}
.divbox .box_area{ width:480px; height:260px; margin:0px auto; padding:0px; font-size:12px; line-height:16px; }
.divbox .box_area .box_left{ width:320px; height:290px; float:left; }
.divbox .box_area .box_left textarea{ width:318px; height:292px; line-height:16px;}
.divbox .box_area .box_right{ width:140px; height:290px; float:right; text-align:left; }
.divbox .box_area .box_right .menu{ width:140px; height:22px; margin:0px auto; padding:0px; border-bottom:1px solid #b0bec7; color:#004B98; font-weight:bold; }
.divbox .box_area .box_right span{ color:red; }
.divbox .box_area .box_right input{ width:120px; height:24px; }

.blankline{height:8px; font-size:1px; clear:both;overflow:hidden;}
.spaceline{width:1px; padding:10px; font-size:1px; float:left; }
</style> 
<script type="text/javascript"> 
//<![CDATA[
var BROWSER = {};
__GetBVar();
if (BROWSER.safari) { BROWSER.firefox = true; }

function __GetBVar() {
    var types = { 'ie': 'msie', 'firefox': '', 'chrome': '', 'opera': '', 'safari': '', 'mozilla': '', 'webkit': '', 'maxthon': '', 'qq': 'qqbrowser' };
    var __ua = navigator.userAgent.toLowerCase();
    var other = 1, ver = 0;
	if(BROWSER.opera){
		ver = opera.version();
		BROWSER.opera = ver;
		BROWSER.name = "opera";
		BROWSER.ver = parseFloat(ver);
	}
	else{
		BROWSER.opera = 0;
	}
    for (i in types) {
        var v = types[i] ? types[i] : i;
        if (__ua.indexOf(v) != -1) {
            var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig');
            var matches = re.exec(__ua);
            ver = matches != null ? matches[2] : 0;
            other = ver !== 0 && v != 'mozilla' ? 0 : other;
			if(!BROWSER.name){
				BROWSER.name = i;
				BROWSER.ver = parseFloat(ver);
			}
        }
        else {
            ver = 0;
        }
        eval('BROWSER.' + i + '= ver');
    }
    BROWSER.other = other;
}

function $(name){ return document.getElementById(name); }
function $set(name, val){ document.getElementById(name).innerHTML = val; }

function Statistics(){
	var str = $('id_content').value.replace(/\r\n/g, "\n");
	var t_str = str.replace(/\n/g, '');
	var w_c_str = str.match(/[\u4e00-\u9fa5]/g)||[];
	var w_e_str = str.match(/\b\w+\b/g)||[];
	var w_n_str = str.match(/\b\d+\b/g)||[];
	var e_p = t_str.match(/[|\~|\`|\!|\@|\#|\$|\%|\^|\&|\*|\(|\)|\-|\_|\+|\=|\||\\|\[|\]|\{|\}|\;|\:|\"|\'|\,|\<|\.|\>|\/|\?]/g)||[];
	
	var sTotal = 0;
	for(var i = 0; i < t_str.length; i++){
		var c = t_str.charAt(i);
		if (c.match(/[^\x00-\xff]/))sTotal ++;
	}
	
	var e = t_str.match(/[A-Za-z]/g)||[];
	var eTotal = e.length;

	var n = t_str.match(/[0-9]/g)||[];
	var nTotal = n.length;

	var part = 0;
	var s_ma = str.split("\n");
	for(var i = 0; i < s_ma.length; i++){
		if(s_ma[i].length > 0) part++;
	}

	$set('id_total', t_str.length);
	$set('id_c_total', w_c_str.length);
	$set('id_c_punctuation', sTotal - w_c_str.length);
	$set('id_e_total', eTotal);
	$set('id_e_punctuation', e_p.length);
	$set('id_e_words', w_e_str.length - w_n_str.length);
	$set('id_n_words', w_n_str.length);
	$set('id_n_total', nTotal);
	$set('id_part', part);
}
function Clear_Content(){
	$('id_content').value = "";

	Statistics();
}
function R_Trim(){
	var str = $('id_content').value.replace(/\r\n/g, "\n").replace(/\n/g, "~");
	var m = str.split("~");
	var ma = [];
	var len = m.length;
	for(var i = 0; i < len; i ++){
		ma.push(m[i].replace(/(\s*$)/g, ""));
	}
	$('id_content').value = ma.join("\r\n");
	
	Statistics();
}
function Section(){
	var str = $('id_content').value.replace(/\r\n/g, "\n").replace(/\n/g, "~");
	var m = str.split("~");
	var ma = [];
	var len = m.length;
	for(var i = 0; i < len; i ++){
		ma.push('    ' + m[i].replace(/(^\s*)|(\s*$)/g, ""));
	}
	$('id_content').value = ma.join("\r\n");

	Statistics();
}
//]]>
</script> 
<meta name="robots" content="index,follow" /> 
<meta name="googlebot" content="index,follow" /> 
</head> 
<body>
<div class="wrapper">
			<!-- main -->
			<div class="main">
					<div class="col_right">
						<div class="mod_border outerbg">
							<em class="cbg ltc"></em>
							<em class="cbg rtc"></em>
							<em class="cbg lbc"></em>
							<em class="cbg rbc"></em>
							<div class="innerbg">
								<div class="intro">
									<h2>字数统计</h2>
									<div class="blood">
										<div class="blood_test">
<div class="divbox">

 <div class="box_area">
  <div class="box_left">
   <textarea id="id_content"></textarea>
<script type="text/javascript"> 
//<![CDATA[
if(BROWSER.ie) $('id_content').onpropertychange = Statistics;
else $('id_content').oninput = Statistics;
//]]>
</script> 
   <div class="blankline"></div>
  </div>
  <div class="box_right">
   <div class="menu">字符统计结果</div>
   <div class="blankline"></div>
   字符总数：&nbsp;<span id="id_total">0</span>&nbsp;个
   <div class="blankline"></div>
   中文字符总数：&nbsp;<span id="id_c_total">0</span>&nbsp;个<br />
   中文标点总数：&nbsp;<span id="id_c_punctuation">0</span>&nbsp;个<br />
   英文字符总数：&nbsp;<span id="id_e_total">0</span>&nbsp;个<br />
   英文标点总数：&nbsp;<span id="id_e_punctuation">0</span>&nbsp;个<br />
   数字字符总数：&nbsp;<span id="id_n_total">0</span>&nbsp;个
   <div class="blankline"></div>
   英文单词总数：&nbsp;<span id="id_e_words">0</span>&nbsp;个<br />
   数据单词总数：&nbsp;<span id="id_n_words">0</span>&nbsp;个<br />
   行（段）总数：&nbsp;<span id="id_part">0</span>
   <div class="blankline"></div>
   <div class="blankline"></div>
   <div>
    <input onclick="Clear_Content()" type="button" value="清空数据" title="清空数据" />
	<div class="blankline"></div>
	<input onclick="R_Trim()" type="button" value="清除行尾空格" title="清除行尾空格" />
	<div class="blankline"></div>
	<input onclick="Section()" type="button" value="段落整理" title="段落整理（段前加空格）" />
   </div>
  </div>
 </div>
</div>
</div>
									</div>
								</div>
							</div>
						</div>

					</div>
			</div>
	</body>
</html>
